"use strict";
const express = require("express");//引入express模块
const app = express();//调用方法生成应用

const bodyParser = require('body-parser');
const e = require("express");
app.use(bodyParser.json());

app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length,Authorization,Accept,X-Requested-With");
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,GELETE,OPTIONS");
    res.header("X-Powered-By", '3.2.1')
    if (req.method == "OPTIONS") res.send(200);
    else next();
});

app.post('/login', function (req, resp) {
    console.log(req.params);
    let data = req.body;
    if (data.userName == 'aaa' && data.password == '123456') {
        resp.send({ succ: true });
    } else {
        resp.send({ succ: false });
    }
});

//Web服务器监听8080端口
app.listen(8080, function () {
    console.log('服务器在8080端口启动！');
});